#include <bits/stdc++.h>
using namespace std;

struct car
{
    int d,v0,a;
}dr[100010];

int p[100010];
int chao[100010];
map<int,int>ji;
int s=1;
int fu[100010];

bool cmp(car x,car y)
{
    if(x.d<y.d)
    {
        return true;
    }
    return false;
}

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--)
    {
        int n,m,l,v;
        cin>>n>>m>>l>>v;
        memset(fu,0,sizeof(fu));
        s=1;
        for(int i=1;i<=n;i++)
        {
            cin>>dr[i].d>>dr[i].v0>>dr[i].a;
        }
        sort(dr+1,dr+1+n,cmp);
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        int sum=0;
        int bi=1;
        bool f=0;
        for(int i=1;i<=n;i++)
        {
            if(dr[i].d>p[m])
            {
                continue;
            }
            if(dr[i].a>0)
            {
                if(v*v<dr[i].v0*dr[i].v0+2*dr[i].a*(p[m]-dr[i].d))
                {
                    sum++;
                    chao[bi]=i;
                    bi++;
                    f=1;
                }
            }
            else if(dr[i].a==0)
            {
                if(dr[i].v0>v)
                {
                    sum++;
                    chao[bi]=i;
                    bi++;
                    f=1;
                }
            }
            else
            {
                int l=1,r=m;
                int mid=(l+r)/2;
                while(l<=r)
                {
                    mid=(l+r)/2;
                    if(p[mid]<=dr[i].d)
                    {
                        if(p[mid]==dr[i].d)
                        {
                            l=mid;
                            break;
                        }
                        l=mid+1;
                    }
                    else
                    {
                        r=mid-1;
                    }
                }
                int k=p[l];
                if(v*v<dr[i].v0*dr[i].v0+2*dr[i].a*(k-dr[i].d))
                {
                    sum++;
                    chao[bi]=i;
                    bi++;
                    fu[s]=i;
                    s++;
                }
            }
        }
        cout<<sum<<" ";
        int sum1=0;
        if(sum==0)
        {
            cout<<m<<endl;
            continue;
        }
        if(s==1)
        {
            cout<<m-1<<endl;
            continue;
        }
        int left=0,right=0,f1=0;
        for(int i=1;i<s;i++)
        {
            int l1,r1;
            if(dr[fu[i]].a<0)
            {
                int l=1,r=m;
                int mid=(l+r)/2;
                while(l<=r)
                {
                    mid=(l+r)/2;
                    if(p[mid]*2*dr[fu[i]].a>=v*v-dr[fu[i]].v0*dr[fu[i]].v0+dr[fu[i]].d*2*dr[fu[i]].a)
                    {
                        if(p[mid]*2*dr[fu[i]].a==v*v-dr[fu[i]].v0*dr[fu[i]].v0+dr[fu[i]].d*2*dr[fu[i]].a)
                        {
                            l=mid;
                            break;
                        }
                        l=mid+1;
                    }
                    else
                    {
                        r=mid-1;
                    }
                }
                r1=l-1;
                l=1,r=m;
                mid=(l+r)/2;
                while(l<=r)
                {
                    mid=(l+r)/2;
                    if(p[mid]<=dr[fu[i]].d)
                    {
                        if(p[mid]==dr[fu[i]].d)
                        {
                            l1=mid;
                            l=mid;
                            break;
                        }
                        l=mid+1;
                    }
                    else
                    {
                        r=mid-1;
                    }
                }
                l1=l;
            }
            //cout<<l1<<" "<<r1<<endl;
            if(f1==0)
            {
                left=l1,right=r1;
                f1=1;
                continue;
            }
            if(l1>=left&&r1<=right)
            {
                left=l1,right=r1;
            }
            else if(l1<=right&&r1>=right)
            {
                left=l1;
            }
            else if(l1>=right&&r1>=right)
            {
                sum1++;
                //cout<<l1<<" "<<r1<<" "<<right<<"x";
                left=l1,right=r1;
            }
        }
        cout<<m-sum1-1<<endl;
    }
    return 0;
}
